package com.rules.admin.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.rules.admin.dao.SysGroupUserRoleDao;
import com.rules.admin.entity.SysGroupUserRole;
import com.rules.admin.service.SysGroupUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysGroupUserRoleServiceImpl extends ServiceImpl<SysGroupUserRoleDao, SysGroupUserRole> implements SysGroupUserRoleService {


   public void insert(SysGroupUserRole[] sysGroupUserRole) {
      this.saveBatch(Lists.newArrayList(sysGroupUserRole));
   }



   public List<SysGroupUserRole> getByUserId(long userId) {
      LambdaQueryWrapper<SysGroupUserRole> queryWrapper = new LambdaQueryWrapper<>();
      queryWrapper.eq(SysGroupUserRole::getUserId, userId);
      return this.baseMapper.selectList(queryWrapper);
   }

   public void deleteByUserId(long id) {
      LambdaQueryWrapper<SysGroupUserRole> queryWrapper = new LambdaQueryWrapper<>();
      queryWrapper.eq(SysGroupUserRole::getUserId, id);
      this.remove(queryWrapper);

   }

   public List<SysGroupUserRole> getByGroupId(long groupId) {
      LambdaQueryWrapper<SysGroupUserRole> queryWrapper = new LambdaQueryWrapper<>();
      queryWrapper.eq(SysGroupUserRole::getGroupId, groupId);
      return this.baseMapper.selectList(queryWrapper);
   }

   public List<SysGroupUserRole> getRole(long id, long groupId) {
      return null;
   }

   public void deleteByIds(long[] ids, long groupId) {

      LambdaQueryWrapper<SysGroupUserRole> queryWrapper = new LambdaQueryWrapper<>();
      queryWrapper.eq(SysGroupUserRole::getGroupId, groupId);
      queryWrapper.in(SysGroupUserRole::getUserId, ids);
      this.remove(queryWrapper);
   }

   public void updateRole(SysGroupUserRole[] sysGroupUserRoles) {
   }

   public void deleteByGroupId(long groupId) {
      LambdaQueryWrapper<SysGroupUserRole> queryWrapper = new LambdaQueryWrapper<>();
      queryWrapper.eq(SysGroupUserRole::getGroupId, groupId);
      this.remove(queryWrapper);
   }
}
